/***************************************************************
 *
 * (c) 2008 Markus Dittrich 
 *
 * This program is free software; you can redistribute it 
 * and/or modify it under the terms of the GNU General Public 
 * License Version 3 as published by the Free Software Foundation. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 3 for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA.
 *
 ****************************************************************/

#ifndef DATALABELWIDGET_H
#define DATALABELWIDGET_H

/* boost includes */
#include <boost/utility.hpp>

/* Qt includes */
#include <QDialog>
#include <QVariant>

/* local includes */
#include "data_label_manager.h"


/* forward declarations */
class QComboBox;
class QGridLayout;
class QHBoxLayout;
class QKeyEvent;
class QLineEdit;
class QVBoxLayout;



/*****************************************************************
 *
 * DataLabelManager provides a simple dialog to enter the
 * labels for the GraphCanvas, the axes, as well as the available
 * data sets
 *
 *****************************************************************/
class DataLabelWidget 
  : 
    public QDialog,
    public boost::noncopyable
{
  Q_OBJECT

public:

  explicit DataLabelWidget(DataLabelManager& theLabels,
      QWidget* parent = 0);


signals:

  void update_canvas();


protected:

  void keyPressEvent(QKeyEvent* anEvent);


private slots:

  void add_axis_labels_to_manager_();
  void add_data_labels_to_manager_();
  void retrieve_current_data_label_(int selectedData);
  void new_label_selected_(int newLabelSelection);
  void left_move_button_pressed_();
  void right_move_button_pressed_();
  void up_move_button_pressed_();
  void down_move_button_pressed_();
  void reset_move_button_pressed_();
  void update_coordinate_widget_();
  void new_coordinate_entered_();


private:

  /* private member functions */
  void generate_main_layout_();
  void generate_main_label_();
  void generate_axis_labels_();
  void generate_data_label_();
  void generate_positioning_grouper_();
  void generate_buttons_();
  void populate_label_selector_();
  void generate_label_selector_widget_(QHBoxLayout* positionLayout);
  void generate_motion_widget_(QHBoxLayout* positionLayout);
  void generate_label_position_widget_(QHBoxLayout* positionLayout);

  /* labels we're working with */
  DataLabelManager& labelManager_;

  /* dialogs widgets and labels */
  QVBoxLayout* mainLayout_;
  QGridLayout* mainLabelLayout_;
  QLineEdit* mainLabelEdit_;
  QLineEdit* xAxisLabelEdit_;
  QLineEdit* yAxisLabelEdit_;
  QLineEdit* dataLabelEdit_;
  QLineEdit* xCoordinateEntry_;
  QLineEdit* yCoordinateEntry_;
  QComboBox* labelSelector_;
  QComboBox* dataSelector_;

  /* general data members */
  int currentMovableLabel_;
};

#endif
